#ifndef HFFDECODETHREAD_H_
#define HFFDECODETHREAD_H_

struct AVPacket;
class HFFDecode;
#include <list>
#include <mutex>
#include <fstream>
#include <string>
#include "hthread.h"
#include "HFFDecode.h"
#include "hframe.h"
#include "htime.h"

typedef struct Opaque {
  datetime_t recv_frame_dt;
  long long sei_time;
  long long recv_frame_time;
} Opaque;

struct AVCodecParameters;

class HFFDecodeThread: public HFFDecode,  public HThread
{
public:
	HFFDecodeThread();
	virtual ~HFFDecodeThread();

  virtual void doTask();
	
	//清理队列
	virtual void Clear();

	//清理资源，停止线程
	virtual void Close();

	virtual int stop();

	//取出一帧数据，并出栈，如果没有返回NULL
	virtual AVPacket *Pop();

	virtual void Push(AVPacket *pkt, UserData* user_data = NULL);

	//最大队列
	int maxList = 50;
	bool isExit = false;

protected:
	std::list <AVPacket *> packs;

private:
  virtual bool doPrepare();
  virtual bool doFinish();

  HFrame          hframe;
};


#endif
